"""

"""
class RedPrint:
    def __init__(self,name):
        self.name=name
        self.mound=[]
    

    def route(self,rule,**options):
        def decorator(f):
            self.mound.append((f,rule,options))
            return f
        return decorator

    def register(self,bp,url_prefix=None):
        #优化红图，加上判断url_prefix后，
        #v1下的__init__.py文件的create_buleprint_v1 方法
        #user.api.register(bp_v1，url_prefix='/book')就可以不传url_prefix参数
        if url_prefix is None:
            url_prefix='/'+self.name
        for f,rule,options in self.mound:
            endpoint=options.pop("endpoint",f.__name__)
            bp.add_url_rule(url_prefix+rule,endpoint,f,**options)
